package com.tianji.learning.controller;


import com.tianji.common.domain.dto.PageDTO;
import com.tianji.learning.domain.dto.QuestionFormDTO;
import com.tianji.learning.domain.page.QuestionPageQuery;
import com.tianji.learning.domain.vo.QuestionVO;
import com.tianji.learning.service.IInteractionQuestionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * <p>
 * 互动提问的问题表 前端控制器
 * </p>
 *
 * @author rui
 * @since 2024-07-21
 */
@RestController
@RequestMapping("/questions")
@RequiredArgsConstructor
@Api(tags = "互动问题相关接口实现")
public class InteractionQuestionController {
    private final IInteractionQuestionService questionService;
    @ApiOperation("新增问题")
    @PostMapping()
    public void saveQuestion(@Valid @RequestBody QuestionFormDTO dto){
        questionService.saveQuestion(dto);
    }
    @ApiOperation("修改问题")
    @PutMapping("/{id}")
    public void updateQuestion(@PathVariable("id") Long id,@RequestBody QuestionFormDTO dto){
        questionService.updateQuestion(id,dto);
    }
    @ApiOperation("分页查询问题")
    @GetMapping("/page")
    public PageDTO<QuestionVO> queryQuestions(QuestionPageQuery pageQuery){
        return questionService.queryQuestions(pageQuery);
    }
    @ApiOperation("根据id查询问题")
    @GetMapping("/{id}")
    public QuestionVO queryByQuestionId(@PathVariable("id") Long id){
        return questionService.queryByQuestionId(id);
    }
    @ApiOperation("根据id删除问题")
    @DeleteMapping("/{id}")
    public void deleteQuestionById(@PathVariable("id") Long id){
         questionService.deleteQuestionById(id);
    }
}
